import E from 'wangeditor'

const {BtnMenu} = E

export class FullScreenMenu extends BtnMenu {
  private isFullScreen = false
  constructor (editor:E) {
    super(E.$(
      `<div class="w-e-menu" data-title="全屏">
      <i class="w-e-icon-fullscreen"></i>
      </div>`
    ), editor)
  }
  clickHandler () {
    const config:any = this.editor.config
    if (!this.isFullScreen) {
      this.editor.fullScreen()
      this.isFullScreen = true
      config.onFullScreen()
    } else {
      this.editor.unFullScreen()
      this.isFullScreen = false
      const toolbar = document.getElementById(this.editor.toolbarElemId)
      // 获取tooltip
      const tooltip = toolbar?.querySelector('.w-e-menu-tooltip')
      if (tooltip) {
        (tooltip as any).style.left = '7px'
      }
      config.onUnFullScreen()
    }
  }
  tryChangeActive () {
  }
}
